home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / newsgroups / misc.19970929-19971216 / 000191_news@newsmaster….columbia.edu _Tue Oct 28 09:42:32 1997.msg < prev    next >
Internet Message Format  |  2020-01-01  |  4KB

  1. Return-Path: <news@newsmaster.cc.columbia.edu>
  2. Received: from newsmaster.cc.columbia.edu (newsmaster.cc.columbia.edu [128.59.35.30])
  3.     by watsun.cc.columbia.edu (8.8.5/8.8.5) with ESMTP id JAA11713
  4.     for <kermit.misc@watsun.cc.columbia.edu>; Tue, 28 Oct 1997 09:42:31 -0500 (EST)
  5. Received: (from news@localhost)
  6.     by newsmaster.cc.columbia.edu (8.8.5/8.8.5) id JAA03830
  7.     for kermit.misc@watsun; Tue, 28 Oct 1997 09:42:31 -0500 (EST)
  8. Path: news.columbia.edu!watsun.cc.columbia.edu!fdc
  9. From: fdc@watsun.cc.columbia.edu (Frank da Cruz)
  10. Newsgroups: comp.protocols.kermit.misc
  11. Subject: Re: Reading filename one at a time.
  12. Date: 28 Oct 1997 14:42:28 GMT
  13. Organization: Columbia University
  14. Lines: 82
  15. Message-ID: <634tkk$d8v$1@apakabar.cc.columbia.edu>
  16. References: <631sbo$hnl$1@goanna.cs.rmit.edu.au>
  17. NNTP-Posting-Host: watsun.cc.columbia.edu
  18. Xref: news.columbia.edu comp.protocols.kermit.misc:7972
  19.  
  20. In article <631sbo$hnl$1@goanna.cs.rmit.edu.au>,
  21. Ross Irvine <rwi@yallara.cs.rmit.edu.au> wrote:
  22. : I have more Kermit questions. :)
  23. : I'd like to do this.
  24. : while (no more files in dirctory)
  25. :     read filename into variable %a
  26. :         send %a
  27. :         if success delete %a
  28. : end loop
  29. That's easy, it's a no-op :-)  Maybe you meant:
  30.  
  31. : while (more files in directory)
  32. :     read filename into variable %a
  33. :         send %a
  34. :         if success delete %a
  35. : end loop
  36.  
  37. By the way, there is a MOVE command that does this (sends one or more files,
  38. and then deletes the source if and only if the transfer was successful).
  39.  
  40. : Basically I'd like to read all the filenames in a directory one at a time 
  41. : so I can work with each file seperately. This is using K95, but will 
  42. : hopefully work in msdos. I've looked through the Kermit book but haven't 
  43. : been able to find anything.
  44. Look on page 398.  Here's a more complete example; modify as desired.
  45. It assumes there is a Kermit server of recent vintage on the far end:
  46.  
  47. ---(cut)---
  48. local \%i \%f \%m \%n
  49. cd desired-directory
  50. assign \%n \ffiles(*)           ; The number of files in this directory.
  51. declare \&a[\%n]                ; Create an array to hold their names.
  52. for \%i 1 \%n 1 {               ; Fill the array
  53.     assign \&a[\%i] \fnextfile()
  54. }
  55. define \%m 0                    ; Counter for successful transfers
  56. set file type binary            ; Transfer in binary mode
  57.  
  58. for \%i 1 \%n 1 {               ; Loop to do each file
  59.     assign \%s \fsize(\&a[\%i]) ; Size of local file we are sending
  60.     send \&a[\%i]               ; Try to send it
  61.     if fail continue            ; If we failed just go on to next one
  62.  
  63.     remote query kermit files(\&a[\%i])
  64.     if equal "\v(query)" "" continue
  65.     if not equal "\v(query)" "1" continue
  66.  
  67.     xif equal "\v(program)" "C-Kermit" {
  68.         remote query kermit crc16
  69.         if equal {\v(query)} {} continue
  70.         if not equal {\v(query)} {\v(crc)} continue
  71.         remote query kermit fsize
  72.         if equal {\v(query)} {} continue
  73.         if not equal {\v(query)} {\%s} continue
  74.     }
  75.     delete \&a[\%i]
  76.     increment \%m                       ; And count it.
  77. }
  78. echo DONE
  79. echo \%m FILE(S) TRANSFERRED.
  80. echo \feval(\%n-\%m) FILE(S) NOT TRANSFERRED.
  81. ---(cut)---
  82.  
  83. Notes:  This script is ultra-paranoid about the success of the transfer.
  84. Really, you could replace the entire script with "move *" and have the
  85. same effect.  But this approach lets you add any other stuff you might like
  86. to do on a per-file basis.
  87.  
  88. The script illustrates how to do extra checking after the transfer: does the
  89. file really exist on the far side?  (Of course it does, or else the SEND would
  90. not have succeeded).  Is its size the same as the source file?  Do the CRC's
  91. match?  If and only if it passes all those tests, it is deleted.  C-Kermit
  92. 6.0, K95 1.1.13, or MS-DOS Kermit 3.15 or later are required.
  93.  
  94. The 'xif equal "\v(program)" "C-Kermit"' section takes advantage of features
  95. that are in C-Kermit 6.0 and K95 but not in MS-DOS Kermit 3.15.  You can use
  96. this same construction to deal with any other differences.
  97.  
  98. - Frank